<?php

// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', preg_replace('|\Smodules\Smod_.*?\Sajax.php|i', '', __FILE__));
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');

$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$user_id = $user->id;
$date = JRequest::getVar("date",null,"post");
if (!$date){
	exit();
}

$db->setQuery("select `date` from `wed_date` where `user_id` = '$user_id' limit 1");

if ($db->loadResult()){
	$query = "update `wed_date` set `date` = '$date' where `user_id` = '$user_id'";
} else {
	$query = "insert into `wed_date` values (NULL,'$user_id','$date')";
}

$db->setQuery($query);

if ($db->query()){
	echo "success";
}

exit();

?>